package vadger.maven.multip.web;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import vadger.maven.multip.business.FancyService;
import vadger.maven.multip.business.Item;

import java.util.List;

/**
 * Homepage
 */
public class HomePage extends WebPage {

	private static final long serialVersionUID = 1L;

	private ListView items;

    /**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
    public HomePage(final PageParameters parameters) {

        // Add the simplest type of label
        add(new Label("message", "Items from fancy service: "));

        items = new ListView<Item>("items", getFancyService().getItemsAllItems()) {

            @Override
            protected void populateItem(ListItem<Item> listItem) {
                listItem.add(new Label("name", listItem.getModelObject().name));
            }
        };

        add(items);
    }

    public FancyService getFancyService() {
        return new FancyService();
    }
}
